﻿using UnityEngine;
using System.Collections;

namespace UI
{
    public class NPCUIFactoryPage : NPCUIPageTemplete {

        public UILabel openTips;
        Dict.DataModel.TableUnionFightNpc npcData;
        public override void SendCSMsg(object o)
        {
            base.SendCSMsg(o);

            npcData = (Dict.DataModel.TableUnionFightNpc)o;
            int cost = 0;
            openTips.text = string.Format(TableTextBlo.GetText("union_fight_open_factory_tips"), cost);
            page.SetActive(true);
            GetComponent<PageTweener>().Play();
        }

        public void OkBtn()
        {
            var factorys = UIUnionFightRunMap.GetNetData().netChariotFactory.chariotFartorys;
            long guid = 0L;
            foreach(var fac in factorys)
            {
                string facId = fac.Value.factoryId + "";
                var dictData = Dict.Blo.DictUnionFightFactoryBlo.GetUnionFightFactoryByID(facId);
                if (dictData.NPCID == npcData.UFNId.ToString())
                {
                    guid = fac.Value.guid;
                    break;
                }
            }
            UIUnionFightRunMap.GetNetData().SendCSUFFieldCariotFactoryOpen(guid, npcData.UFNId+"");
            Close();
        }

        public void Cancel()
        {
            Close();
        }
    }

}
